﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JeuDeDames_v1._02
{
    [Serializable]
    public class Pion : Piece
    {
      
        #region Constructeurs
        public Pion(int p, Joueur j, bool adv = false)
        {
            this.pos = p;
            this.j = j;
            this.pas = 1;
            this.adv = adv;
        }
        #endregion

        #region Méthodes
        public void promotion(Damier d)
        {
            for (int i = 0; i < 5; i++)
            {
                if (j.indicePromote[i] == this.pos)
                {
                    j.lesPieces.Remove(this);
                    j.nbPieces--;
                    (d.damier[this.pos] as CaseN).piece = new Dame(this.pos, this.j);
                    j.lesPieces.Add((d.damier[this.pos] as CaseN).piece);
                    j.nbPieces++;
                    j.nbDames ++;
                    return;
                }
            }
            return;
        }//promotion();

        public override string ToString()
        {
            if (j.couleur == BLANC)
            {
                if (adv)
                    return "o";
                return "x";
            }
            else if (j.couleur == NOIR)
            {
                if (adv)
                    return "x";
                return "o";
            }
            else
                return " ";
        
        }//ToString();
        #endregion
    }
}
